<template>
  <div class="doc-card" @click="emit('docClick', doc.id)">
    <div class="doc-cover">
      <img :src="doc.coverUrl" :alt="doc.name">
    </div>
    <span class="doc-title">{{ doc.name }}</span>
    <div class="doc-meta">
      <span class="doc-data">{{ doc.createTime ? doc.createTime.split(' ')[0] : '' }}</span>
      <div class="view">
        <span class="doc-views">{{ doc.views }}</span>
        <svg-icon name="view" class="eye-icon"></svg-icon>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import SvgIcon from '@/components/SvgIcon/index.vue'

defineProps<{
  doc: DocData
}>()

const emit = defineEmits<{
  docClick: [id: string | number]
}>()

</script>

<style scoped>
.doc-card {
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}
.doc-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}
.doc-cover {
  width: 100%;
  height: 180px;
  overflow: hidden;
  position: relative;
}
.doc-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.doc-card:hover .doc-cover img {
  transform: scale(1.2);
}
.doc-title {
  padding: 12px;
  font-size: 14px;
  color: #333;
  line-height: 1.4;
  height: 30px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin: 0;
  background: #fff;
}
.doc-meta {
  padding: 8px 5px;
  display: flex;
  justify-content: space-between;
  color: #999;
  font-size: 12px;
  border-top: 1px solid #f0f0f0;
  background: #fff;
}
.view{
  position: relative;
  display: flex;
  align-items: center;
}
.eye-icon{
  width: 16px;
  height: 16px;
  position: absolute;
  left: -17px;
}
</style>
